package com.kensure.task;

import javax.annotation.Resource;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import co.kensure.frame.Const;

import com.kensure.shike.order.service.SKFinPayService;
import com.kensure.shike.user.service.SKUserFRService;

@Service
public class SKTask {

	@Resource
	private SKFinPayService sKFinPayService;
	@Resource
	private SKUserFRService sKUserFRService;

	/**
	 * add by fankd 每天0点，\结束活动\结算活动
	 */
	@Scheduled(cron = "0 0 7 1/1 * ?")
	public void deleteLogData() {
		if (!Const.isStart()) {
			System.out.println("定时任务未开启");
			return;
		}

	}

	/**
	 * add by fankd 每天10点，抽奖
	 */
	@Scheduled(cron = "0 0 10 1/1 * ?")
	public void choujiang1() {
		if (!Const.isStart()) {
			System.out.println("定时任务未开启");
			return;
		}

	}

	/**
	 * add by fankd 每天15点，抽奖
	 */
	@Scheduled(cron = "0 0 15 1/1 * ?")
	public void choujiang2() {
		if (!Const.isStart()) {
			System.out.println("定时任务未开启");
			return;
		}

	}

	/**
	 * add by fankd 每天20点，抽奖
	 */
	@Scheduled(cron = "0 0 20 1/1 * ?")
	public void choujiang3() {
		if (!Const.isStart()) {
			System.out.println("定时任务未开启");
			return;
		}

	}

	/**
	 * add by fankd 每天22点，补充抽奖
	 */
	@Scheduled(cron = "0 0 22 1/1 * ?")
	public void choujiang4() {
		if (!Const.isStart()) {
			System.out.println("定时任务未开启");
			return;
		}

	}

	/**
	 * add by fankd 每10分钟调度一次，关闭订单,分润，到账
	 */
	@Scheduled(cron = "0 4/10 * * * ? ")
	public void quxiao() {
		if (!Const.isStart()) {
			System.out.println("定时任务未开启");
			return;
		}
		try {
			sKFinPayService.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		try {
			// 设置收款后的状态
			sKFinPayService.fkop();
		} catch (Exception e) {
			e.printStackTrace();
		}
		try {
			sKUserFRService.commitZhang();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
